1
|
|
|
Amarkal.settings.fields = { |
|
|
|
|
2
|
|
|
$form: null, |
3
|
|
|
$fields: null, |
4
|
|
|
init: function () { |
5
|
|
|
this.$form = $('#amarkal-settings-form'); |
6
|
|
|
this.$fields = this.$form.find('.amarkal-settings-field'); |
7
|
|
|
}, |
8
|
|
|
hideAll: function () { |
9
|
|
|
this.hide(this.$fields); |
10
|
|
|
}, |
11
|
|
|
showAll: function () { |
12
|
|
|
this.show(this.$fields); |
13
|
|
|
}, |
14
|
|
|
showBySection: function (slug) { |
15
|
|
|
this.hideAll(); |
16
|
|
|
this.show(this.$fields.filter('[data-section="'+slug+'"]')); |
17
|
|
|
}, |
18
|
|
|
search: function(query) { |
19
|
|
|
var matches = []; |
20
|
|
|
var $form = this.$form; |
21
|
|
|
|
22
|
|
|
this.$fields.each(function(){ |
23
|
|
|
var $field = $(this), |
24
|
|
|
title = $field.find('h3').text().toLowerCase(), |
25
|
|
|
help = $field.find('.help-content').text(); |
26
|
|
|
description = $field.find('.description').text(); |
|
|
|
|
27
|
|
|
|
28
|
|
|
// Don't add fields that are currently hidden |
29
|
|
|
if(!$form.amarkalUIForm('isVisible', $field.attr('data-name'))) return; |
|
|
|
|
30
|
|
|
|
31
|
|
|
// Check query against the field's title |
32
|
|
|
if(title.match(query) || description.match(query) || help.match(query)) { |
33
|
|
|
matches.push($field); |
34
|
|
|
} |
35
|
|
|
}); |
36
|
|
|
|
37
|
|
|
// Convert the matches array to a jQuery object |
38
|
|
|
return $(matches).map(function(){return this.toArray();}); |
39
|
|
|
}, |
40
|
|
|
show: function($fields) { |
41
|
|
|
var _this = this; |
42
|
|
|
$fields.each(function(){ |
43
|
|
|
$comp = $(this).find('.amarkal-ui-component'); |
|
|
|
|
44
|
|
|
|
45
|
|
|
// Only show components whose visibility condition is satisfied |
46
|
|
|
if(_this.$form.amarkalUIForm('isVisible', $comp.amarkalUIComponent('getName'))) { |
47
|
|
|
$(this).addClass('visible'); |
48
|
|
|
$comp.amarkalUIComponent('refresh'); |
49
|
|
|
} |
50
|
|
|
}); |
51
|
|
|
}, |
52
|
|
|
hide: function($fields) { |
53
|
|
|
$fields.removeClass('visible'); |
54
|
|
|
}, |
55
|
|
|
flag: function(type, fieldName) { |
56
|
|
|
this.$fields.filter('[data-name="'+fieldName+'"]').addClass('flag-'+type); |
57
|
|
|
}, |
58
|
|
|
unflagAll: function() { |
59
|
|
|
this.$fields.removeClass('flag-error flag-notice'); |
60
|
|
|
} |
61
|
|
|
}; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.